<?php
namespace Common\Controller;
use Common\Controller\AppframeController;

class HomecommController extends CommController {
	
	public function __construct() {
		// $this->set_action_success_error_tpl();
		parent::__construct();
	}
	
	function _initialize() {
		parent::_initialize();
		// defined('TMPL_PATH') or define("TMPL_PATH", C("JSD_TMPL_PATH"));
		// $site_options=get_site_options();
		
	    if(!session('?mycity'))
		{
			session('mycity','成都');
		}
		if(!session('?citype'))
		{
			session('citype','1');
		}
		$this->assign($site_options);
		$ucenter_syn=C("UCENTER_ENABLED");
		
		//进行初始化的设置，记录地址
		if($ucenter_syn){
		    $session_user = session('user');
			if(empty($session_user)){
				if(!empty($_COOKIE['thinkcmf_auth'])  && $_COOKIE['thinkcmf_auth']!="logout"){
					$thinkcmf_auth=sp_authcode($_COOKIE['thinkcmf_auth'],"DECODE");
					$thinkcmf_auth=explode("\t", $thinkcmf_auth);
					$auth_username=$thinkcmf_auth[1];
					$users_model=M('Users');
					$where['user_login']=$auth_username;
					$user=$users_model->where($where)->find();
					if(!empty($user)){
						$is_login=true;
						session('user',$user);
					}
				}
			}else{
			}
		}
		//城市/市场
		$m = M ( "Market" );
		$citys =$m->distinct(true)->field('mkc')->select();
		$mks =$m->distinct(true)->field('mkname')->select();
		$this->assign ( "citys", $citys );
		$this->assign ( "mks", $mks );
		//友情链接
		$link = M ( "Link" );
		$linklist =$link->order('sort desc')->select();
		$this->assign ( "linklist", $linklist );
	}
	

    //验证验证码是否正确方法
    Public function checkVerify($code){
		$verify = md5("jinrongkuanggong".$code);
		$verifycode = session('verifycode');
		if($verify == $verifycode){
			return 1;
		}else{
			return 0;
		}
    }

}